import { reqCategoryList, reqGetBannerList } from "@/api";
//home模块小仓库
//存储数据仓库
const state={
    categoryList:[],
    bannerList:[]
};
//修改state的唯一手段
const mutations={
    CATEGORYLIST(state,categoryList){
        state.categoryList = categoryList
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList=bannerList
    }
};
//处理action，可以书写自己的业务逻辑
const actions={
    //通过api接口，调用后端数据
    async categoryList({commit}){
        let result= await reqCategoryList();
        if(result.code == 200){
            commit('CATEGORYLIST',result.data)
        }
    },
    async getBannerList({commit}){
        let result = await reqGetBannerList();
        if(result.code==200){
            commit('GETBANNERLIST',result.data)
        }
    }
};
//计算属性
const getters={};

export default ({
    state,
    mutations,
    actions,
    getters
});